import * as vscode from 'vscode';

const outputChannel = vscode.window.createOutputChannel(
  'Component Compile', { log: true }
);

export const logger = {
  // 原生日志方法
  info: (message: string) => {
    outputChannel.info(message);
    outputChannel.show(true);
  },
  error: (message: string) => {
    outputChannel.error(message);
    outputChannel.show(true);
  },
  warn: (message: string) => {
    outputChannel.warn(message);
    outputChannel.show(true);
  },
  debug: (message: string) => {
    outputChannel.debug(message);
    outputChannel.show(true);
  },
  
  // 自定义日志方法
  repo: (message: string) => {
    outputChannel.info(`[repo] - ${message}`);
    outputChannel.show(true);
  },

  hb: (message: string) => {
    outputChannel.info(`[hb] - ${message}`);
    outputChannel.show(true);
  },
  
  append: (message: string) => {
    outputChannel.appendLine(message);
    outputChannel.show(true);
  },
  // 输出错误日志，同时包含调用堆栈信息
  errorWithStack: (message: string) => {
    const error = new Error(message);
    outputChannel.error(`Error: ${message}`);
    outputChannel.error(`Stack trace: ${error.stack}`);
    outputChannel.show(true);
  },
  
  // 日志通道原生方法
  show: (preserveFocus?: boolean) => outputChannel.show(preserveFocus),
  hide: () => outputChannel.hide(),
  clear: () => outputChannel.clear(),
  dispose: () => outputChannel.dispose()
}; 